#include "table.h"
#include "rule.h"

using namespace fouine;
using namespace std;

Table::Table()
{}

Table::Table(RuleId nb_rules_, StrLen str_length_, StrLen max_length_)
:_nb_rules(nb_rules_),
 _str_length(str_length_),
 _max_length(max_length_)
{
  _t = new Likelihood**[_max_length+1];
  for (StrLen l=0 ; l<=_max_length ; l++) {
    _t[l] = new Likelihood*[_nb_rules];
    for (RuleId r=0 ; r < _nb_rules; r++) {
      _t[l][r] = new Likelihood[_str_length-l];
    }
  }
}

Table::~Table()
{
  for (StrLen l=0 ; l<=_max_length ; l++) {
    for (RuleId r=0 ; r < _nb_rules; r++)
      delete[] _t[l][r];
    delete[] _t[l];
  }
  delete[] _t;
}
